package com.example.easytts.controller

import com.example.easytts.model.Word
import com.example.easytts.repository.WordRepository
import org.slf4j.LoggerFactory
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/api/word")
class WordController(private val wordRepository: WordRepository) {
    private val logger = LoggerFactory.getLogger(WordController::class.java)

    @GetMapping("/by-category")
    fun getWordsByCategory(@RequestParam category: String): List<Word> {
        logger.info("收到前端category参数: '$category'")
        val result = wordRepository.findByCategory(category)
        logger.info("查询到单词数量: ${result.size}")
        return result
    }
} 